package cn.estore.util;
import java.sql.*;
public class DBConnection {
//    加载数据库驱动
    private String dbDriver="com.mysql.cj.jdbc.Driver";
    private String url="jdbc:mysql://localhost:3306/e-store?useSSL=false&iseImocpde=true&characterEncoding=UTF-8&serverTimezone=GMT%2B8";
    public Connection connection=null;
    public DBConnection(){
        try {
            Class.forName(dbDriver).newInstance();//加载数据库驱动
            connection =DriverManager.getConnection(url,"root","yao123456");
        }catch (Exception ex){
            ex.printStackTrace();
            System.out.println("数据库加载失败 ");
        }
    }
}


